/**
 * 评论模型
 * @module models/Comment
 */

const { DataTypes } = require('sequelize');
const { sequelize } = require('../config/database');

/**
 * 评论模型定义
 * @typedef {Object} Comment
 * @property {number} articleId - 文章ID
 * @property {string} username - 用户名
 * @property {string} email - 邮箱
 * @property {string} content - 评论内容
 * @property {boolean} approved - 是否审核通过
 */
const Comment = sequelize.define('Comment', {
  username: {
    type: DataTypes.STRING,
    allowNull: false,
    validate: {
      notEmpty: true,
      len: [2, 50]
    }
  },
  email: {
    type: DataTypes.STRING,
    allowNull: false,
    validate: {
      isEmail: true
    }
  },
  content: {
    type: DataTypes.TEXT,
    allowNull: false,
    validate: {
      notEmpty: true,
      len: [2, 1000]
    }
  },
  approved: {
    type: DataTypes.BOOLEAN,
    allowNull: false,
    defaultValue: false
  }
});

module.exports = Comment; 